<?php
require_once 'renderer_field.php';

class renderer_dropdown extends renderer_field
{
    
    public function editRender($fObject)
    {
        $this->lead->viewer->fObject = $fObject;
        $this->lead->viewer->fRenderer = $this;

        
        $options = $fObject->getOptions();
        $selected = $fObject->getValue();

        $this->lead->viewer->selected = $selected;
        $this->lead->viewer->options = $options;

        $config = $fObject->getConfig();
        return $this->lead->viewer->fetch("{$this->path}/{$this->folderName}/edit_{$config['render_as']}.tpl");
    }
    
    
    public function searchRender($fObject)
    {
        $this->lead->viewer->fObject = $fObject;
        $this->lead->viewer->fRenderer = $this;
        
        $this->lead->viewer->items = $fObject->getOptions();
        
        return $this->lead->viewer->fetch("{$this->path}/{$this->folderName}/search.tpl");
    }
    
    
    public function viewRender($fObject)
    {
        $options = $fObject->getOptions();
        if(key_exists($fObject->getValue(), $options))
        {
            return $options[$fObject->getValue()];
        }
        
        
    }
    
}